/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package my.presentation;

import boundary.IngredienceFacade;
import entities.Ingredience;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

/**
 *
 * @author Michal Vachler
 */
@ManagedBean(name = "IngredienceView")
@RequestScoped
public class IngredienceView {
    @EJB
    private IngredienceFacade ingredienceFacade;

    // Creates a new field
    private Ingredience ingredience;

    public Ingredience getIngredience() {
        return ingredience;
    }
    // Returns the total number of messages
    public int getNumberOfMessages(){
       return ingredienceFacade.findAll().size();
    }

    // Saves the message and then returns the string "theend"
    public String saveIngredience(){
       this.ingredienceFacade.create(ingredience);
       return "nova_ingredience";
    }
    
    /**
     * Creates a new instance of MessageView
     */
    public IngredienceView() {
        this.ingredience = new Ingredience();
    } 
}
